<?php
/*
Template Name: 登录
*/
if (is_user_logged_in()){
	wp_redirect(get_option('home'));
}
?>
<?php get_header(); ?>
<script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.validate.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.form.js"></script>
<style>
form.registerform label.error, label.error {
	color: red;
}
form.registerform p {
	margin-left:20%;
}
form.registerform span{
	margin-right:5px;
	font-size:14px;
}
form.registerform #output{
	width:260px;
	text-align:center;
}
</style>
<div id="content" class="content">
	<div id="innerContent">
	<div class="textbox">
	<div class="textbox_header"></div>
	<div class="textbox_inner">
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="textbox-title" id="post-<?php the_ID(); ?>">
                <h1>登录</h1>
            </div>
            <div class="textbox-content article-content">
            	<div><?php the_content('<p class="serif">' . __('Read the rest of this page &raquo;', 'kubrick') . '</p>'); ?></div>
            	<div id="respond">
            	<form class='registerform' action="<?php echo get_option('siteurl'); ?>/mangse-login.php?act=login" method="post" id="registerform">
            	<p>
				<span for='author'>登录名称</span>
				<input type="text" name="author" id="author" size="22" tabindex="1" />
				</p>
				<p>
				<span for='password'>你的密码</span>
				<input type="password" name="password" id="password" size="22" class="required" tabindex="3" />
				</p>
				<p id='output' style="color:#fff;background-color:red;"></p>
				<p>
				<span style='visibility:hidden;'>登录芒色</span>
				<input name="mangse_submit" type="submit" id="mangse_submit" tabindex="5" value="登录" />
				<a href="<?php echo get_option('home').'/wp-login.php?action=lostpassword'?>">忘记密码?</a>
				</p>
				</form>
				</div>
            	<p class="postmetadata">
            	<small style="color:#aaa;"><?php echo get_option('home'); ?></small>
            	</p>
            </div>
            	<?php endwhile; endif; ?>
		</div>
				<div class="textbox_footer"></div>
			</div>
	</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<script type="text/javascript">
var login=function(form){
	var options = {
			target:'#output',
			success:function(error){
				if(error=='登录成功'){
				$('#mangse_submit').attr("disabled", "true");
					location.href='<?php echo get_option('home'); ?>';
					}
			}
	};
	$(form).ajaxSubmit(options);
	//$('#mangse_submit').attr("disabled", "true");
};
$.validator.setDefaults({
	submitHandler: function(form) {
		login(form);
		return false;
	}
});
$(document).ready(function() {
	$('input').focus(function(){
		$('#output').html('');
	});
	$("#registerform").validate({
		rules: {
			author: {
				required: true,
			},
			password: {
				required: true,
			}
		},
		messages: {
			author: {
				required: "请输入登录名称",
			},
			password: {
				required: "请输入密码"
			}
		}
	});
});
</script>